import java.io.BufferedReader;
import java.io.FileReader;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.IOException;

/**
 *
 * @author Andy
 */
public class WordImporter {
    public static void main(String[] args) {
        DatabaseConnection dbConnect = new DatabaseConnection();
        try {
            String curLine;
            String query;
            BufferedReader bufRead = new BufferedReader(new FileReader("src/word_list.txt"));
            int newId = 1;
            while((curLine = bufRead.readLine()) != null) {                
                dbConnect.connect();
                
                query = String.format("INSERT INTO words VALUES(%d, '%s')", newId, curLine.trim());
                dbConnect.executeUpdate(query);
                
                newId++;
            }
            
            bufRead.close();
        }
        catch (IOException e) {
            System.err.println("Not good on the finding the file end");
        }
        finally {
            dbConnect.closeConnection();
        }
    }
}
